
package GUI;

import Kernel.Billet;
import Kernel.Client;
import Kernel.ProfilPassager;
import Kernel.Trajet;

public class Etape2_Avion extends javax.swing.JFrame {
    
	private static final long serialVersionUID = -6942559538103054650L;
	private Trajet t;
	private Client ct;
	
    /** Créé une instance de Avion */
    public Etape2_Avion() {
        initComponents();
        t = new Trajet();
        ct = new Client();
        this.setLocationRelativeTo(this.getParent());
    }
    /**
     *  Créé une instance de Avion paramétrée
     * @param t représente le trajet sélectionné avant
     */
    public Etape2_Avion(Trajet t){
        initComponents();
        this.t = t;
        ct = new Client();
        this.jTextField_infoType.setText(t.getTypeDeBase());
        this.jTextField_infoType.setEditable(false);
        if(this.jTextField_infoType.getText().compareTo("Non modifiable")==0)
        		this.jCheckBox_modif.setEnabled(true);
        else this.jCheckBox_modif.setEnabled(false);
        this.setLocationRelativeTo(this.getParent());
    }
    
    /**
	 * Initialisation des composants d'AWT.
	 */	
    private void initComponents() {                         
		jLabel_type = new javax.swing.JLabel();
		jCheckBox_modif = new javax.swing.JCheckBox();
		jLabel_classe = new javax.swing.JLabel();
		jComboBox_classe = new javax.swing.JComboBox();
		jCheckBox_repas = new javax.swing.JCheckBox();
		jCheckBox_fidelite = new javax.swing.JCheckBox();
		jTextField_infoType = new javax.swing.JTextField();
		jButton_suivant = new javax.swing.JButton();
		jLabel_Etape2 = new javax.swing.JLabel();
		jComboBox1 = new javax.swing.JComboBox();
		jButton_retour = new javax.swing.JButton();
		jLabel_typeP = new javax.swing.JLabel();

		setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

		jLabel_type.setText("Type de billet proposé :");

		jCheckBox_modif.setText("Rendre modifiable");

		jLabel_classe.setText("Classe :");

		jComboBox_classe.setModel(new javax.swing.DefaultComboBoxModel(
				new String[] { "Standard", "Affaire", "Première" }));

		jCheckBox_repas.setText("Repas");

		jCheckBox_fidelite.setText("Carte de fidélité");

		jButton_suivant.setText("Suivant");
		jButton_suivant.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton_suivantActionPerformed(evt);
			}
		});

		jLabel_Etape2.setText("Etape 2 - Avion :");

		jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] {
				"Adulte", "Enfant","Enfant non-accompagné", "Etudiant", "Jeune", "Senior" }));

		jButton_retour.setText("Retour");
		jButton_retour.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton_retourActionPerformed(evt);
			}
		});

		jLabel_typeP.setText("Type de passager :");

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
				getContentPane());
		getContentPane().setLayout(layout);
		layout.setHorizontalGroup(layout
				.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(
						layout.createSequentialGroup()
								.addContainerGap()
								.addGroup(
										layout.createParallelGroup(
												javax.swing.GroupLayout.Alignment.LEADING)
												.addGroup(
														layout.createSequentialGroup()
																.addComponent(
																		jLabel_Etape2)
																.addContainerGap(
																		454,
																		Short.MAX_VALUE))
												.addGroup(
														javax.swing.GroupLayout.Alignment.TRAILING,
														layout.createSequentialGroup()
																.addComponent(
																		jButton_retour)
																.addGap(28, 28,
																		28)
																.addComponent(
																		jButton_suivant)
																.addGap(137,
																		137,
																		137))
												.addGroup(
														javax.swing.GroupLayout.Alignment.TRAILING,
														layout.createSequentialGroup()
																.addGroup(
																		layout.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.LEADING)
																				.addGroup(
																						layout.createSequentialGroup()
																								.addComponent(
																										jLabel_classe)
																								.addPreferredGap(
																										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																								.addComponent(
																										jComboBox_classe,
																										javax.swing.GroupLayout.PREFERRED_SIZE,
																										javax.swing.GroupLayout.DEFAULT_SIZE,
																										javax.swing.GroupLayout.PREFERRED_SIZE)
																								.addGap(189,
																										189,
																										189))
																				.addGroup(
																						javax.swing.GroupLayout.Alignment.TRAILING,
																						layout.createSequentialGroup()
																								.addGroup(
																										layout.createParallelGroup(
																												javax.swing.GroupLayout.Alignment.TRAILING)
																												.addGroup(
																														javax.swing.GroupLayout.Alignment.LEADING,
																														layout.createSequentialGroup()
																																.addComponent(
																																		jLabel_typeP)
																																.addPreferredGap(
																																		javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																																.addComponent(
																																		jComboBox1,
																																		0,
																																		189,
																																		Short.MAX_VALUE))
																												.addGroup(
																														layout.createSequentialGroup()
																																.addComponent(
																																		jLabel_type)
																																.addPreferredGap(
																																		javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																																.addComponent(
																																		jTextField_infoType,
																																		javax.swing.GroupLayout.DEFAULT_SIZE,
																																		156,
																																		Short.MAX_VALUE)))
																								.addGap(52,
																										52,
																										52)))
																.addGroup(
																		layout.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.LEADING,
																				false)
																				.addGroup(
																						layout.createSequentialGroup()
																								.addComponent(
																										jCheckBox_repas)
																								.addContainerGap(
																										javax.swing.GroupLayout.DEFAULT_SIZE,
																										Short.MAX_VALUE))
																				.addGroup(
																						javax.swing.GroupLayout.Alignment.TRAILING,
																						layout.createSequentialGroup()
																								.addComponent(
																										jCheckBox_modif)
																								.addGap(29,
																										29,
																										29))
																				.addGroup(
																						layout.createSequentialGroup()
																								.addComponent(
																										jCheckBox_fidelite)
																								.addContainerGap()))))));
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(jLabel_Etape2)
            .addGap(44, 44, 44)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel_type)
                .addComponent(jTextField_infoType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jCheckBox_modif))
            .addGap(40, 40, 40)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel_typeP)
                .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGap(52, 52, 52)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel_classe)
                .addComponent(jComboBox_classe, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jCheckBox_repas))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
            .addComponent(jCheckBox_fidelite)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 46, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jButton_suivant)
                .addComponent(jButton_retour))
            .addContainerGap())
    );

    pack();
}           

    private void jButton_retourActionPerformed(java.awt.event.ActionEvent evt) { 
    	Etape11 e = new Etape11();
    	this.setVisible(false);
    	e.setVisible(true);
        
        this.dispose();
    }       
    
    private void jButton_suivantActionPerformed(java.awt.event.ActionEvent evt) {
    	// On enregistre les différentes informations dans un billet
    	Billet billet;
    	String typePassager = jComboBox1.getSelectedItem().toString();
    	if(typePassager.compareTo("Enfant non-accompagné") == 0){
    		billet = new Billet(ProfilPassager.valueOf("ENFANT_NON_ACCOMPAGNE"), ct ,  t);
    	}
    	else {
    		billet = new Billet(ProfilPassager.valueOf(typePassager.toUpperCase()), ct ,  t);
    	}
        // Classe Affaire
        if(jComboBox_classe.getSelectedItem().toString().compareTo("Affaire") == 0){
        	billet.setClasseAffaire(true);
        }
        // Première classe
        else if(jComboBox_classe.getSelectedItem().toString().compareTo("Première") == 0){
        	billet.setPremiereClasse(true);
        }
        // Modifiable
        billet.setModifier(jCheckBox_modif.isSelected());
        /// Repas
        billet.setRepas(jCheckBox_repas.isSelected());
        // Carte de fidélité
        billet.setCarteFidelite(jCheckBox_fidelite.isSelected());
        // On affiche la fenêtre suivante
        Bilan b = new Bilan(this.t,billet);
        this.setVisible(false);
        b.setVisible(true);
        
    }                                               
                       
    private javax.swing.JButton jButton_retour;
    private javax.swing.JButton jButton_suivant;
    private javax.swing.JCheckBox jCheckBox_fidelite;
    private javax.swing.JCheckBox jCheckBox_modif;
    private javax.swing.JCheckBox jCheckBox_repas;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBox_classe;
    private javax.swing.JLabel jLabel_Etape2;
    private javax.swing.JLabel jLabel_classe;
    private javax.swing.JLabel jLabel_type;
    private javax.swing.JLabel jLabel_typeP;
    private javax.swing.JTextField jTextField_infoType;                  
    
}
